Katya Baldina
Please submit all assignments on Canvas in .doc, .docx, or .pdf file!
Click the Submit Assignment button and then upload the file
## [1] 4.5
mean() function to do calculation and
give you a valid output## Error in Mean(1:8): could not find function "Mean"
Mean() does not exist
in R## Error: <text>:1:5: unexpected symbol
## 1: mea n
## ^
mea n(), because in R no
function can have space in it.You also have to always have equal number of open and close parentheses
## Error: <text>:3:0: unexpected end of input
## 1: mean(1:8
## 2:
## ^
R would not give you a result. Instead you will see the
+ sign, which will encourage you to end the code of
line.
To resolve this issue you can either
Add the missing parantheses
Click Esc to terminate the running of a function
How can RStudio know the location of the file?
Working directory is a folder that R will refer to when you ask it to load files. If the files that you ask to load are not in the working directory, R will give you an error.
You can change the location of the working directory either temporarily or permanently. I recommend to set up the working directory at the beginning of your code each time, because often you need to store files from different projects in different folders.
To check working directory, type:
## [1] "/Users/KATE1/Library/CloudStorage/OneDrive-IndianaUniversity/Active/Fall 2023/S371_Lab/Lab"
To change working directory, type:
setwd('/Users/KATE1/Desktop')
getwd() #To check that working directory changed, run this command again!## [1] "/Users/KATE1/Desktop"
Now you can see that your working directory has changed!
In RStudio, you can also change the location of the working directory going to Session –> Set Working Directory –> Choose Directory
Then look for the folder you want to set up as the working directory.
For the further guide, you can refer to this resource:
If you want to change the location of working directory permanently, you can do it in RStudio.
Just go to Tools–>Global Options
Click the browse button and change the default location of the working directory.
Two ways to open a file in RStudio:
Highlight the lines of code that you want to run:
Then press the run button at the top of your script
OR
Mac Users: Command+Enter
Windows Users: Ctrl+Enter
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
Comments
Anything that starts with # is a comment and ignored by R
Comments are useful to make notes about your code, so that you know what you are doing.